{template 'common/header'}
<div class="page-group">
    <div class="page page-current" id="page-goods-list">
		{template 'common/followed'}
		{template 'common/footbar'}
		<div class="content infinite-scroll" data-distance="10" data-type="js">
		<div class="g-body">
		 	<div class="m-index">
		 		<!-- ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓幻灯片开始↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ -->
		        {if $advs}
				<div id="banner_box" class="box_swipe">
					<ul>
						{loop $advs $adv}
						<li>
							<a {if $adv['link'] != 'http://'}href="{$adv['link']}"{/if}>
								<img src="{php echo tomedia($adv['thumb']);}" style='width:100%;' />
							</a>
		
						</li>
						{/loop}
					</ul>
					<ol>
						{php $slideNum = 1;} {loop $advs $adv}
						<li{if $slideNum==1 } class="on" {/if}></li>
						{php $slideNum++;} {/loop}
					</ol>
				</div>
				<script>
					$(function() {
				        new Swipe($('#banner_box')[0], {
				            speed:500,
				            auto:3000,
				            callback: function(){
				                var lis = $(this.element).next("ol").children();
				                lis.removeClass("on").eq(this.index).addClass("on");
				            }
				        });
				    });
				</script>
				{/if}
				<!-- <div class="yJoinNum">
					<input id="People" type="hidden" value="">
					<a href="javascript:void(0);" target="_blank" class="allNums">
					    <b>累计注册人数</b>
						{loop $mtotals $numb}
						<span class="yNumList"><ul><li t="9">9</li><li t="8">8</li><li t="7">7</li><li t="6">6</li><li t="5">5</li><li t="4">4</li><li t="3">3</li><li t="2">2</li><li t="1">1</li><li t="0">0</li></ul></span>
						{/loop}
					</a>
				</div> -->
				<!-- ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑幻灯片结束↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ -->
				<!-- ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓自定义菜单开始↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ -->
				{if $navis}
				<div class="s_index_icon" style="padding-bottom: 0px;">
			        <div class="swiper-wrapper" id="c_main_Prefecture">
				    	<ul class="s_index_ul" style="">
				    		{loop $navis $navi}
				    		<li><a {if $navi['link'] != 'http://'}href="{$navi['link']}"{/if}><img src="{php echo tomedia($navi['thumb']);}"><em>{$navi['name']}</em></a></li>
				    		{/loop}
				    	</ul>
			        </div>
			   	</div>
			   	{/if}
			   	<!-- ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑自定义菜单结束↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ -->
			   	<!-- ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓滚动揭晓开始↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ -->
			   	<!--<div class="x_new_publish">
			        <ul class="x_newest_publish" id="publishData" style="margin-top: -120px;"><li>恭喜<a href="/person_records_win-90.html">火星人</a>获得<span><a href="/publish_detail_result-6-2.html">中国移动 话费充值卡面值30元</a></span></li><li>恭喜<a href="/person_records_win-90.html">火星人</a>获得<span><a href="/publish_detail_result-9-1.html">中国移动 话费充值卡面值1000元</a></span></li><li>恭喜<a href="/person_records_win-781.html">1938</a>获得<span><a href="/publish_detail_result-5-76.html">中国移动 话费充值卡面值10元</a></span></li><li>恭喜<a href="/person_records_win-645.html">8652</a>获得<span><a href="/publish_detail_result-11-1.html">中国联通 话费充值卡面值100元</a></span></li><li>恭喜<a href="/person_records_win-687.html">9321</a>获得<span><a href="/publish_detail_result-3-99.html">中国联通 话费充值卡面值10元</a></span></li><li>恭喜<a href="/person_records_win-385.html">云购这么整不...</a>获得<span><a href="/publish_detail_result-7-3.html">中国移动 话费充值卡面值100元</a></span></li><li>恭喜<a href="/person_records_win-616.html">9453</a>获得<span><a href="/publish_detail_result-2-146.html">中国电信 话费充值卡面值30元</a></span></li><li>恭喜<a href="/person_records_win-521.html">8848</a>获得<span><a href="/publish_detail_result-4-43.html">中国联通 话费充值卡面值30元</a></span></li><li>恭喜<a href="/person_records_win-616.html">9453</a>获得<span><a href="/publish_detail_result-2-145.html">中国电信 话费充值卡面值30元</a></span></li><li>恭喜<a href="/person_records_win-90.html">火星人</a>获得<span><a href="/publish_detail_result-2-144.html">中国电信 话费充值卡面值30元</a></span></li></ul>
			    </div>-->
			    <!-- ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑滚动揭晓结束↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ -->
			   <!-- ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓最新揭晓开始↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ -->
			    <div class="c_new_publish">
			        <h2>
			          <a href="{php echo $this->createMobileUrl('jump',array('template'=>'newannounce'))}">最新揭晓</a>
			        </h2>
			        <ul class="c_newest_publish" id="c_newest_publish">
			        	<div class="infinite-scroll-preloader" id = 'ann_ref'>
					      	<div class="preloader"></div>
					    </div>
			         	<!-- ↓↓↓↓↓最新揭晓数据开始↓↓↓↓↓ -->
			         	
			        	<!-- ↑↑↑↑↑最新揭晓数据结束↑↑↑↑↑ -->
			        </ul>
			    </div>
			    <!-- ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑最新揭晓结束↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ -->
			    <!-- ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓首页商品展示开始↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ -->
			    <div class="c_new_goods b_index_fixed1">
			        <ul class="c_goods_title b_index_fixed" style="position: relative; top: 0px; left: 0px; z-index: 149;">
			          <li class="c_hot_color" val-data="fast">最快</li>
			          <li val-data="new">最新</li>
			          <li val-data="hot">最热</li>
			          <li val-data="priceup">价格 <i class="fa fa-long-arrow-up"></i></li>
			          <li val-data="pricedown">价格 <i class="fa fa-long-arrow-down"></i></li>
			        </ul>
			        <dl class="c_goods_details" id="dataList">
			          	<!-- ↓↓↓↓↓商品数据开始↓↓↓↓↓ -->
			        	
			        	<!-- ↑↑↑↑↑商品数据结束↑↑↑↑↑ -->
			      	</dl>
				  	<div id="dataMore" class="more">
				      	<div class="c_clear"></div>
				       	<div class="c_click_see" id="loading" style="display: none; background: none;">
				       	<img alt="loading" src="/static/img/loading2.gif" style="height:30px">
				       	</div>
					</div>
					<div class="infinite-scroll-preloader" id="preloader">
				      	上拉、试试
				    </div>
			    </div>
			    <!-- ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑首页商品展示结束↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ -->
		    </div>
		</div>
		{template 'common/footer'}
		</div>
	</div>
</div>
<!-- ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓最新揭晓嵌入模块开始↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ -->
<script type="text/html" id="nowannounce">
	{{# for(var i = 0, len = d.result.length; i < len; i++){ }}
	<li>
		<div class="c_newest_publish_text" id = "text_{{ d.result[i].id }}">
			<div style="height:40px;  overflow: hidden;line-height: 20px;">
				<a href="{php echo $this->createMobileUrl('detail')}&periodid={{ d.result[i].id }}">(第{{ d.result[i].periods }}期){{ d.result[i].title }}</a>
			</div>
			{{# if(d.result[i].endtime > d.result[i].nowtime){ }}
			<p class="c_publish_time" id="time_{{ d.result[i].id }}">
				<span id="mm_10_{{ d.result[i].id }}">-</span><span id="mm_1_{{ d.result[i].id }}">-</span><span class="c_colon">:</span><span id="ss_10_{{ d.result[i].id }}">-</span><span id="ss_1_{{ d.result[i].id }}">-</span><span class="c_colon">:</span><span id="pp_10_{{ d.result[i].id }}">-</span><span id="pp_1_{{ d.result[i].id }}">-</span>
			</p>
			<div style="font-size:12px;line-height: 20px;height: 20px;overflow: hidden;display: none;" id = 'win_{{ d.result[i].id }}'><span style="float: left;">恭喜： </span><span style="float: left;width: 64px;overflow:hidden ;">{{d.result[i].nickname}}</span></div>
			{{# }else{ }}
			<div style="font-size:12px;line-height: 20px;height: 20px;overflow: hidden;"><span style="float: left;">恭喜： </span><span style="float: left;width: 64px;overflow:hidden ;">{{d.result[i].nickname}}</span></div>
			{{# } }}
		</div>
		<div class="c_newest_publish_img">
			<a href="{php echo $this->createMobileUrl('detail')}&periodid={{ d.result[i].id }}">
				<img src="{{ d.result[i].picarr }}" class="img-responsive publish" style="width:95%;height: 40px;" alt="{{ d.result[i].title }}">			        				
			</a>
		</div>
	</li>
	{{# } }}
</script>
<!-- ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑最新揭晓嵌入模块结束↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ -->
<!-- ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓商品嵌入模块开始↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ -->
<script type="text/html" id="goodslist">
	{{# for(var i = 0, len = d.result.length; i < len; i++){ }}
	<dd>
		<div class="c_goods_size">
			<a href="{php echo $this->createMobileUrl('detail')}&id={{ d.result[i].id }}">
				<img id="img_{{ d.result[i].id }}" data-original="{{ d.result[i].picarr }}" class="img-responsive lazy2" style="width: 100%; display: block;" src="{{ d.result[i].picarr }}">
			</a>
		</div>
		<a href="#">(第{{ d.result[i].periods }}期){{ d.result[i].title }}</a>
		<p>开奖进度<span>{{ d.result[i].scale }}%</span></p>
		<div class="c_shopping_cart">
			<div class="c_progress_box">
				<span style="width:{{ d.result[i].scale }}%"></span>
			</div>
			<div class="c_addshopping_cart" onclick="addToCart('{{ d.result[i].period_number }}','{{ d.result[i].title }}')"></div>
		</div>
		{{# if(d.result[i].init_money == 10){ }}
		<div class="c_region_icon c_ten"></div>
		{{# } }}
	</dd>
	{{# } }}
</script>
<!-- ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑商品嵌入模块结束↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ -->
<!-- ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓商品倒计时js开始↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ -->
<script>
    var strr ='{php echo date('Y-m-d H:i:s',time())}';
    	strr = strr.replace(/-/g,"/");
    var nowtime = new Date(strr);//当前时间
    var now_time = parseInt(nowtime.getTime());
//商品揭晓倒计时方法
function freshtime(endtime,id,nickname){
	var starttime = new Date(endtime.replace(/-/g,"/"));//开始时间
    var start_time = parseInt(starttime.getTime());
    now_time += 11;
    var lefttime = (start_time - now_time)/1000;
    if(lefttime > 0){
    	m_10 = parseInt(((lefttime/60)%60)/10);
    	m_1 = parseInt(((lefttime/60)%60)%10);
    	
    	s_10 = parseInt((lefttime%60)/10);
    	s_1 = parseInt((lefttime%60)%10);
    	
    	p_10 = parseInt((lefttime - parseInt(lefttime))*10);
    	p_1 = parseInt((lefttime - parseInt(lefttime))*100) - parseInt((lefttime - parseInt(lefttime))*10)*10;
    	
    	document.getElementById('mm_10_'+id).innerHTML = m_10;
    	document.getElementById('mm_1_'+id).innerHTML = m_1;
    	document.getElementById('ss_10_'+id).innerHTML = s_10;
    	document.getElementById('ss_1_'+id).innerHTML = s_1;
    	document.getElementById('pp_10_'+id).innerHTML = p_10;
    	document.getElementById('pp_1_'+id).innerHTML = p_1;
    }else{
    	var p = document.getElementById('time_'+id);
    	var t = document.getElementById('win_'+id);
    	p.remove();
    	t.style.display = 'block';
    	return false;
    }
}

function actionTimer(endtime,id,nickname) {
    var g = window.setInterval(function() {
        freshtime(endtime,id,nickname)
    },
    10)
}
function bindAccumulativePeople() {
	var a = 0; 
    var f = {$mtotal};
    $("#People").val(f);
    var c = [];
    for (i = a = 0; i < f.length; i++) a = f.slice(i, i + 1),
    c.push(a);
    $(".yNumList ul").css("marginTop", "-180px");
    var g = 0;
    for (i = 0; i < c.length; i++) g = f[i],
    $($(".yNumList ul")[i]).animate({
        marginTop: 20 * g - 180
    },
    1E3);
    if ($(".yNumList").length < c.length) for (a = c.length - $(".yNumList").length, i = 0; i < a; i++) $($(".yNumList")[0]).clone(!0).insertAfter($($(".yNumList")[$(".yNumList").length - 1]));
    setInterval(function() {
        $(".yJoinNum input").val(parseInt($(".yJoinNum input").val()));
        c = [];
        f = $(".yJoinNum input").val();
        for (i = 0; i < f.length; i++) {
            var a = f.slice(i, i + 1);
            c.push(a)
        }
        if ($(".yNumList").length < c.length) for (a = c.length - $(".yNumList").length, i = 0; i < a; i++) $($(".yNumList")[0]).clone(!0).insertAfter($($(".yNumList")[$(".yNumList").length - 1]));
        $(".yNumList ul").css("marginTop", "-180px");
        for (i = 0; i < c.length; i++) g = f[i],
        $($(".yNumList ul")[i]).animate({
            marginTop: 20 * g - 180
        },
        1E3)
    },
    3E3)
}
function newWinner() {
    var a = 0;
    $($(".x_newest_publish li")[0]).clone(!0).insertAfter($($(".x_newest_publish li")[$(".x_newest_publish li").length - 1]));
    setInterval(function() {
        a -= 40;
        a >= 40 * -($(".x_newest_publish li").length - 2) ? $(".x_newest_publish").animate({
            marginTop: a
        },
        2E3) : $(".x_newest_publish").animate({
            marginTop: a
        },
        2E3,
        function() {
            a = 0;
            $(".x_newest_publish").css({
                marginTop: 0
            })
        })
    },
    4E3)
};
</script>
<!-- ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑商品倒计时js结束↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ -->

<script>
	$(function() {
		'use strict';
		//商品列表页
		$(document).on("pageInit", "#page-goods-list", function(e, id, page) {	
			bindAccumulativePeople();
			newWinner();
			/******加载首页最新揭晓******/
			var page_num = 4;
			var page_start = 0;

			function addAnnounceItems(announce_num,announce_page){
				var announceAjaxUrl = "{php echo $this->createMobileUrl('index')}"+"&op="+"announce"+"&announce_num="+ announce_num +"&announce_page=" + announce_page;
				$.ajax({
					type: "POST",
					url: announceAjaxUrl,
					dataType: 'json',
					beforeSend: function(XMLHttpRequest) {},
					success: function(data) {
						if (data.result.length > 0) {
							var gettpl = document.getElementById('nowannounce').innerHTML;
							laytpl(gettpl).render(data, function(html){
							    $(".c_newest_publish").html(html);
							});
							for(var i = 0, len = data.result.length; i < len; i++){
								//判定是否需要加载时间
								if(data.result[i].endtime > data.result[i].nowtime){
									actionTimer(data.result[i].change_endtime,data.result[i].id,data.result[i].nickname);
								}
							}
						} else {
							$("#ann_ref").remove();			//移除最新揭晓的刷新效果
							$(".loading_more").remove();
							$('.noData').show();
						}
					},
					error: function() {
						$('.error').show();
					}
				});
			}
			addAnnounceItems(page_num,page_start);	//第一次进入加载
			
			/***********加载商品数据方法***********/
			var page_goods = 0;
			var op_goods = 'fast';
			var flag_goods = 0;		//数据加载完成标记
			
			function addGoodsItems(page,op){
				document.getElementById('preloader').innerHTML = '<div class="preloader"></div>';	//开启加载动态
				var goodsAjaxUrl = "{php echo $this->createMobileUrl('index')}"+"&op="+ op +"&page="+ page;
				$.ajax({
					type: "POST",
					url: goodsAjaxUrl,
					dataType: 'json',
					beforeSend: function(XMLHttpRequest) {},
					success: function(data) {
						if (data.result.length > 0) {
							var gettpl = document.getElementById('goodslist').innerHTML;
							laytpl(gettpl).render(data, function(html){
							    $("#dataList").append(html);
							    document.getElementById('preloader').innerHTML = '上拉加载更多';		//关闭加载动态
							});
						} else {
							document.getElementById('preloader').innerHTML = '商品已加载完成';
							flag_goods = 1;
						}
					},
					error: function() {
						$('.error').show();
					}
				});
			}
			addGoodsItems(page_goods,op_goods);	//第一次进入加载
			
			/************商品类别方法************/
			$('.c_goods_title').find('li').click(function(){
				var op = $(this).attr('val-data');
				$(this).addClass('c_hot_color').siblings().removeClass('c_hot_color');
				document.getElementById('dataList').innerHTML = '';	//清空原有商品
				op_goods = op;		//重新定义全局变量
				page_goods = 0;		//重新定义全局变量
				flag_goods = 0;		//初始化数据加载完成标记
				addGoodsItems(page_goods,op_goods);
			});
			/**********刷新加载商品**********/
			$(page).on('infinite', function() {
				page_goods++;
				if(flag_goods == 0){
					addGoodsItems(page_goods,op_goods);
				}
			});
		});
		$.init();
	});
</script>
<script>
function addToCart(periodnumber,title){
	
	$.post("{php echo $this->createMobileUrl('cart',array('op'=>'tocart'))}"
		,{periodnumber:periodnumber,title:title}
		,function(d){
			if(d.result==1){
				$.toast('添加到购物车成功');
				$('#c_total_num').html(d.num);
			}
		}
		,"json"
	);
}
</script>
</body>
</html>